<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>修改诗人信息</title>
</head>
<body>
	<!-- {name:"小白",age:1231,guoji:"韩国",techang:"剑术"}, -->

	<form action="http://192.168.1.114:3000/wenxue/shirenupdateInfo" method='post'>
		<input type="hidden" name="name" value="<%=aaa.name%>"><br>
		<b><%=aaa.name%></b><br>
		年龄:<input type="number" name="age" value="<%=aaa.age%>"><br>
		国籍:<input type="text" name="guoji" value="<%=aaa.guoji%>"><br>
		特长:<input type="text" name="techang" value="<%=aaa.techang%>"><br>
		<!-- <input type="submit" value="确定"> -->
		<input type="button" onclick="submitUpdate()" value="确定修改">
	</form>

	<script>
		//提交表单的修改
		function submitUpdate(argument) {
			var url="/wenxue/shirenupdateInfo";
			var f1=document.forms[0];
			var xhr= new XMLHttpRequest();
			xhr.open('POST',url);
			xhr.setRequestHeader("Content-Type"  
        , "application/x-www-form-urlencoded");  
			xhr.onload=function (e) {
				console.log("接受的信息是%s",xhr.response);
				location.href="/wenxue/shirens";
			}
			xhr.send(serilazed(document.forms[0]));
		}

		function serilazed(form) {
			//过滤出来要序列化的表单项
			var aaa=Array.prototype.slice.apply(form.children)
			aaa=aaa.filter(function (item) {
				
				return item.tagName=='INPUT' && item.name;
			}).map(function (item) {
				return item.name+"="+item.value;
			});
			return aaa.join('&');
		}
	
	</script>
</body>
</html>